package com.kunyi.web.im.websocket.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;


/**
 * @ClassName DataEntity
 * @Description 客户端发送socket类型枚举类.
 * @Author zhenguo.zhuang
 * @Date 2024/03/29
 * @Version 1.0
 **/
@Getter
@AllArgsConstructor
public enum SocketCommand {

        HEARTBEAT("o","心跳"),
        NO_SUBSCRIBE("noSubscribe","取消订阅"),
        SUBSCRIBE("subscribe","订阅"),
        INSTANT_MESSAGING("instantMessaging","即时通讯");
        private String code;
        private String desc;

    public static SocketCommand getSocketCommand(String code) {
        switch (code) {
            case "o":
                return SocketCommand.HEARTBEAT;
            case "subscribe":
                return SocketCommand.SUBSCRIBE;
            case "noSubscribe":
                return SocketCommand.NO_SUBSCRIBE;
            case "instantMessaging":
                return SocketCommand.INSTANT_MESSAGING;
            default:
                return null;
        }
    }

}
